<?php
    include_once("../service/categoryService.php");

    $name = $_POST["name"];
    $parentID = $_POST["parentID"] == "" ? "NULL" : $_POST["parentID"];
    $description = $_POST["description"];

    $actionResult = insertCategory($parentID, $name, $description);

    if($actionResult)
        echo "<script>window.location = '../admin-page/category.php?keyword=$name'</script>";
    else
        echo "<script>window.location = '../admin-page/category.php?actionResult=noadd'</script>";
    
?>
